@echo off
REM Set UTF-8 encoding
chcp 65001 > nul

REM Enable delayed variable expansion
setlocal enabledelayedexpansion

echo ==================== Start Checking New Files ====================
echo Current Time: %date% %time%

REM Get untracked files directly
echo Found new files:
for /f "delims=" %%a in ('git ls-files --others --exclude-standard') do (
    echo Adding: %%a
    call git add "%%a"
)

REM Check if files were added
git diff --cached --quiet
if %errorlevel% neq 0 (
    echo Committing changes...
    call git commit -m "commit res"
    echo Pushing...
    call git push origin master
    echo Complete!
) else (
    echo No new files found, nothing to commit
)

echo ==================== Execution Complete ====================
echo Finish Time: %date% %time%
pause